package demo.observer;


/**
 * @author : feixiang.li
 * @since : 2025-09-17 16:46
 */
public class Main {
    public static void main(String[] args) {

        TvStation tvStation = new TvStation();
        // 天气站-》 拿到了事件天气
        WeatherStation weatherStation = new WeatherStation(tvStation);
        User user = new User("张三", info -> {
            if (info.contains("晴天")) {
                System.out.println("晴天：出去玩啦");
            } else {
                System.out.println("阴天： Stay at home");
            }
        });

        User user1 = new User("李四", info -> {
            if (info.contains("阴天")) {
                System.out.println("李四:雨：带伞");
            } else {
                System.out.println("李四:晴天：去玩");
            }
        });

        // 发布订阅模式。事件生产者-》总线 -〉 订阅者
        tvStation.subscribe(user, WeatherUpdateEvent.class);
        tvStation.subscribe(user1, WeatherUpdateEvent.class);

        weatherStation.start();
    }
}
